package zero.tech.games.log.controller;

import java.text.ParseException;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.core.util.DatetimeUtil;
import zero.tech.games.log.service.api.ILogsService;
@RestController
public class LogsController extends BaseController{
	@Autowired
	private ILogsService logsService;
	
	@RequestMapping("/list-playback-by-page")
	public Resp listPlaybackByPage(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int game_id=Integer.valueOf(map.get("game_id").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.listPlaybackByPage(simpleUser,club_id,game_id,begin,end,page,pageLength);
	}
	
	
	@RequestMapping("/get-playback-detail")
	public Resp getPlaybackDetail(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		int game_id=Integer.valueOf(map.get("game_id").toString());
		String room_id=map.get("room_id").toString();
		String play_code=map.get("play_code").toString();
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.getPlaybackDetail(simpleUser,club_id,game_id,room_id,play_code,begin,end);
	}
	
	
	
	@RequestMapping("/operate-baoxiangui-logs")
	public Resp operateBaoxianguiLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.operateBaoxianguiLogs(simpleUser,club_id,begin,end,page,pageLength);
	}
	
	@RequestMapping("/gold-change-logs")
	public Resp goldChangeLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		int type=Integer.valueOf(map.get("type").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.goldChangeLogs(simpleUser,club_id,begin,end,page,pageLength,type);
	}
	
	
	@RequestMapping("/invite-line-logs")
	public Resp inviteLineLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		Integer uid=null;
		if(map.containsKey("uid")) {
			uid=Integer.valueOf(map.get("uid").toString());
		}
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.inviteLineLogs(simpleUser,club_id,uid,begin,end,page,pageLength);
	}
	
	
	@RequestMapping("/water-team-logs")
	public Resp waterTeamLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		int type=Integer.valueOf(map.get("type").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.waterTeamLogs(simpleUser,club_id,begin,end,page,pageLength,type);
	}
	
	@RequestMapping("/water-zsteam-logs")
	public Resp waterZsTeamLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		Integer uid=null;
		if(map.containsKey("uid")) {
			uid=Integer.valueOf(map.get("uid").toString());
		}
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.waterZsTeamLogs(simpleUser,club_id,uid,begin,end,page,pageLength);
	}
	
	
	@RequestMapping("/water-reward-get-logs")
	public Resp waterRewardGetLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.waterRewardGetLogs(simpleUser,club_id,begin,end,page,pageLength);
	}
	
	@RequestMapping("/shangxiafen-logs")
	public Resp shangxiafenLogs(HttpServletRequest request,@RequestBody Map<String,Object> map) throws ParseException {
		SimpleUser simpleUser=super.getLoginUser(request);
		int club_id=Integer.valueOf(map.get("club_id").toString());
		Integer uid=null;
		if(map.containsKey("uid")) {
			uid=Integer.valueOf(map.get("uid").toString());
		}
		String begin_time=String.valueOf(map.get("begin_time").toString());
		String end_time=String.valueOf(map.get("end_time").toString());
		int page=Integer.valueOf(map.get("page").toString());
		int pageLength=Integer.valueOf(map.get("pageLength").toString());
		Date begin=DatetimeUtil.parseStringToDate("yyyy-MM-dd", begin_time);
		Date end=DatetimeUtil.parseStringToDate("yyyy-MM-dd", end_time);
		return logsService.shangxiafenLogs(simpleUser,club_id,begin,end,page,pageLength,uid);
	}
}
